//
//  YCTrainMethodButton.m
//  YCSchool
//
//  Created by Yanglixia on 16/5/1.
//  Copyright © 2016年 yanglinxia. All rights reserved.
//  带右箭头的button

#import "YCTrainMethodButton.h"

@interface YCTrainMethodButton ()
/** 右边箭头imageView */
@property (nonatomic, strong) UIImageView *rightImageView;
@end
@implementation YCTrainMethodButton

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        [self setTitleColor:[UIColor yc_colorWithUInt:0x808080] forState:UIControlStateNormal];
        self.backgroundColor = [UIColor whiteColor];
        self.titleLabel.font = [UIFont systemFontOfSize:14];
        self.titleLabel.text = @"前往班车";
        self.layer.cornerRadius = 5;
        self.layer.masksToBounds = YES;
        self.layer.borderColor = [UIColor yc_colorWithUInt:0xf0f0f0].CGColor;
        self.layer.borderWidth = 1;

        self.imageView.contentMode = UIViewContentModeScaleToFill;
        
        UIImageView *rightImageView = [[UIImageView alloc] init];
        rightImageView.image = [UIImage imageNamed:@"right_arrow"];
        rightImageView.contentMode = UIViewContentModeCenter;
        [self addSubview:rightImageView];
        self.rightImageView = rightImageView;
        
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    [self.titleLabel sizeToFit];
    [self.imageView sizeToFit];
    CGFloat margin = self.frame.size.width;
    margin = (margin - self.titleLabel.yc_width - 23) / 4.0;
    
    self.imageView.frame = CGRectMake(margin,(self.frame.size.height - 15)/2.0, 15, 15);
    self.titleLabel.frame = CGRectMake(2 * margin + 15, 0, self.titleLabel.yc_width, self.frame.size.height);
    self.rightImageView.frame = CGRectMake(3 * margin + 15 + self.titleLabel.yc_width, 0,8, self.frame.size.height);
}

- (void)setFrame:(CGRect)frame
{
    
}


@end
